package com.example.classcommunity3.dao;

import com.example.classcommunity3.model.Homework;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.util.List;

public interface HomeworkDao extends CrudRepository<Homework, Long> {

    List<Homework> findByHSubCode(String subCode);

    Homework findByHId(Long hId);

    @Transactional
    @Modifying
    @Query(nativeQuery = true, value ="DELETE FROM homework WHERE h_sub_code = ?1" )
    int deleteByHSubCode(String subCode);

}
